<template>
  <div class="success_box">
    <div class="nr_box">
      <div class="bj">
        <img src="https://yxzw.oss-cn-chengdu.aliyuncs.com/rich/20230713/1bbtp4YGfiLA0ZHXDGEg.png" alt="">
        <p :style="{height:navBarHeight+'px'}"></p>

      </div>
      <div class="box">
        <div class="title_box">
          <img src="/static/images/success_icon.png" alt="">
          预定成功
        </div>
        <p class="line"></p>
        <div class="msg_box" :style="{height:height+'rpx'}">
          <p class="jb" v-if="height"></p>
          <p class="price"><span>￥</span>{{msg.realPrice}}</p>
          <div class="line_box">
            <p class="quan"></p>
            <p class="xian"></p>
            <p class="quan"></p>
          </div>
          <div class="box">
            <p class="title">订单编号</p>
            <p class="text">{{msg.orderCode}}</p>
          </div>
          <div class="box">
            <p class="title">下单时间</p>
            <p class="text">{{msg.createTime}}</p>
          </div>
          <div class="box">
            <p class="title">支付方式</p>
            <p class="text">{{msg.payType?'钱包支付':'微信支付'}}</p>
          </div>
          <div class="anniu_box">
            <p @click="toOrder">我的订单</p>
            <p @click="openDoor">立即开门</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
 
<script>
import { Debounce } from "@/utils/index";
import { 
  getPaySuccessOrder,
  orderUnLock
} from "@/api/index";
export default {
  components: {
  },
  data() {
    return{
      statusBarHeight: "", // 状态栏高度
      titleBarHeight: "", // 标题栏高度
      navBarHeight: "", // 导航栏总高度
      height:0,
      msg:{}
    }
  },
  onShow() {
    setTimeout(() => {
      this.height = 650
    }, 500);
  },
  methods: {
    // 开门
    openDoor:Debounce(function () {
      this.$showLoading('开门中...')
      orderUnLock({orderId:this.msg.id}).then(res=>{
        if(res.statusCode == '00000'){
          wx.hideLoading()
          this.$toast('开门成功')
          setTimeout(() => {
            wx.navigateTo({
              url: `/pages/order_xq/main?orderId=${this.msg.id}`,
            });
          }, 500);
        }else{
          wx.hideLoading()
          this.$toast(res.message)
        }
      })
    },300),


    toOrder(){
      wx.switchTab({
        url: "/pages/order/main",
      });
    },

    getOrderMsg(orderId){
      getPaySuccessOrder({orderId}).then(res=>{
        if(res.statusCode == '00000'){
          this.msg = res.data
        }
      })
    }
  },
  onHide() {},
  onLoad(options) {
    console.log(options)
    this.getOrderMsg(options.orderId)
  },
  beforeMount() {
    const self = this;
    wx.getSystemInfo({
      success(system) {
        console.log(`system:`, system);
        self.statusBarHeight = system.statusBarHeight;
        let platformReg = /ios/i;
        if (platformReg.test(system.platform)) {
          self.titleBarHeight = 44;
        } else {
          self.titleBarHeight = 48;
        }
        self.navBarHeight = self.statusBarHeight + self.titleBarHeight;
      },
    });
  },
  onUnload() {
    this.height = 0
  },
  created() {}
};
</script>

<style lang="scss"  scoped>
.success_box {
  width: 100%;
  min-height: 100vh;
  background: #F5F5F5;
  .nr_box{
    width: 100%;
    padding-bottom:50rpx;
    .bj{
      img{
        display: block;
        position: fixed;
        top:0;
        left: 0;
        width: 100%;
        height: 420rpx;
        z-index: 10;
      }
    }
    .box{
      position: relative;
      z-index: 10;
      .title_box{
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 36rpx;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #FFFFFF;
        img{
          width: 90rpx;
          height: 90rpx;
          margin-right:16rpx;
        }
      }
      .line{
        width: 90%;
        height: 24rpx;
        background: #28AE28;
        border-radius: 30rpx;
        margin:40rpx auto 0 auto;
      }
      .msg_box{
        background: #fff;
        width: 86%;
        height: 0;
        margin:0 auto;
        margin-top:-10rpx;
        border-bottom-right-radius: 16rpx;
        border-bottom-left-radius: 16rpx;
        transition: all 1.5s;
        overflow: hidden;
        .jb{
          width: 100%;
          height: 50rpx;
          background: linear-gradient(to bottom, #a3eea3 0%, #ffffff 50%);
        }
        .price{
          width: 90%;
          margin:0 auto;
          font-size:60rpx;
          font-family: PingFangSC-Medium, PingFang SC;
          font-weight: 500;
          color:#FF5226;
          text-align: center;
          padding-bottom:40rpx;
          span{
            font-size:32rpx;
          }
          
        }
        .line_box{
          display: flex;
          justify-content: space-between;
          align-items: center;
          margin-bottom:20rpx;
          .quan{
            width: 30rpx;
            height: 30rpx;
            background: #F5F5F5;
            border-radius: 50%;
            position: relative;
            left:-12rpx;
            &:last-child{
              left: 12rpx;
            }
          }
          .xian{
            width: 88%;
            height: 1px;
            border-bottom: 2rpx dashed #CECECF;
          }
        }
        .box{
          margin:0 30rpx;
          display: flex;
          align-items: center;
          justify-content: space-between;
          font-size: 28rpx;
          font-family: PingFangSC-Regular, PingFang SC;
          height: 70rpx;
          .title{
            color:#666666;
          }
          .text{
            color:#111111;
          }
        }
      }
      .anniu_box{
        display: flex;
        align-items: center;
        justify-content: center;
        margin-top:80rpx;
        p{
          width: 40%;
          height: 80rpx;
          line-height: 80rpx;
          border-radius: 40rpx;
          border: 2rpx solid #00C200;
          font-size: 32rpx;
          font-family: PingFangSC-Medium, PingFang SC;
          font-weight: 500;
          color: #00C200;
          text-align: center;
          &:last-child{
            margin-left:48rpx;
            background: #00C200;
            color:#fff;
          }
        }
      }
    }
  }
}
</style>
